package com.zhuang.chapter07.work02;

import java.util.Scanner;

import com.zhuang.chapter09.work02.CargoBoat;
import com.zhuang.chapter09.work02.DangerException;

public class TestDangerException {

	public static void main(String[] args) {
		CargoBoat cargoBoat = new CargoBoat();
		Scanner sc = new Scanner(System.in);
		cargoBoat.setMaxcontent(100);
		int m = 0;
		try {
			while (true) {
				System.out.println("请输入装载箱重量,当前装载箱重量为" + cargoBoat.getMaxcontent() + "吨");
				m = sc.nextInt();
				cargoBoat.loading(m);
			}
		} catch (DangerException e) {
			e.showError();
			System.out.printf("无法再装载重量是%d吨的集装箱\n", m);
		} finally {
			System.out.printf("启航出发！");
		}
		sc.close();

	}
}
